package cn.qiyu5522.tk_ems.controller.admin;


import cn.qiyu5522.tk_ems.result.R;
import cn.qiyu5522.tk_ems.service.DictService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.constraints.NotBlank;

/**
 * <p>
 * 数据字典 前端控制器
 * </p>
 *
 * @author Tonkey
 * @since 2023-02-23
 */
@Api(tags = "数据字典")
@RestController
@RequestMapping("admin/dict")
public class DictController {

    @Resource
    private DictService dictService;

    @ApiOperation("根据pid获取对应数据列表")
    @ApiImplicitParam(name="parentId",value = "父级编号", required = true, dataType = "Long")
    @GetMapping("/queryDataListByPid/{parentId}")
    public R queryDataListByPid(@NotBlank(message = "parentId未传入") @PathVariable Long parentId){
        return dictService.queryDataListByPid(parentId);
    }

    @ApiOperation("根据名称查询编号")
    @ApiImplicitParam(name="name",value = "名称", required = true, dataType = "String")
    @GetMapping("/queryDictIdByName/{name}")
    public R queryDictIdByName(@NotBlank(message = "name未传入") @PathVariable String name){
        return dictService.queryDictIdByName(name);
    }



}
